<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta name="author" content="Ionel Alexandru">
	<meta name="reply-to" content="ionel.alexandru@gmail.com">
	<title>fMath Editor - www.fmath.info</title>
	<script type="text/javascript" src="../internal.js"></script>
	
	
</head>
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
	<table width="920" height="460">
	<tr height="100%">
		<td align="center">
		<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="910" height="460" id="editML" name="editML" align="middle">
			<param name=wmode value="transparent">
			<param name="allowScriptAccess" value="always"/>
			<param name="allowFullScreen" value="true"/>
			<param name="loop" value="false"/>
			<param name="quality" value="high" />
			<param name="flashVars" value="configUrl=configMathMLEditor.xml&loadOnInit=true"/>
			<param name="movie" value="mathml/MathMLEditor.swf?configUrl=configMathMLEditor.xml&loadOnInit=true" />
			<embed src="mathml/MathMLEditor.swf?configUrl=configMathMLEditor.xml&loadOnInit=true"
	            wmode="transparent"
				flashVars="configUrl=configMathMLEditor.xml&loadOnInit=true"
				loop="false"
				quality="high"
				width="910"
				height="460"
                id="editML"
				name="editML"
				align="middle"
                swliveconnect="true"
				allowScriptAccess="always"
				allowFullScreen="true"
				type="application/x-shockwave-flash"
				pluginspage="http://www.adobe.com/go/getflashplayer" />
		</object>
		</td>
	</tr>
	</table>

<script>


	function getMathMLFromJavascript(name){
		document.getElementById('editML').focus();
		return "<mrow><mtext>...</mtext></mrow>";
	}

	function setMathMLToEditor(mathml){
		getSWF("editML").setMathML(mathml);
	}


	function getMathMLFromEditor(){
		return getSWF("editML").getMathML();
	}

	var ed;
	var name;
	var saved = false;
	
	dialog.onok=function saveImage(){
		if(saved) return;
		saved=true;
		getSWF("editML").saveImageOnServer();
	}

	function setFileNameFromServer(n){
		name = trim(n);
		setTimeout('saveAndUpdate()', 10);
	}


	function saveAndUpdate(){
			var mathml = getMathMLFromEditor();
			editor.execCommand('insertHtml',"<img src='"+name+"' border='0' />" );

	}

	function getSWF(movieName) {
		if (navigator.appName.indexOf("Microsoft") != -1) {
			return document.getElementById(movieName);
		}else {
			if (document.embeds && document.embeds[movieName]){
				  return document.embeds[movieName];
			}
				if(document[movieName].length != undefined){
				return document[movieName][1];
				}
				return document[movieName];
		}
	}

	function trim(str, chars) {
	  return ltrim(rtrim(str, chars), chars);
	}
	function ltrim(str, chars) {
	  chars = chars || "\\s";
	  return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
	}
	function rtrim(str, chars) {
	  chars = chars || "\\s";
	  return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
	}

</script>

</body>
</html>
